const {
	app,
	Menu,
	Tray
} = require('electron')
const path = require('path')

const handleTray = () => {
	let tray = new Tray(path.join(__dirname, "../", "static", "icon.png"))
	const contextMenu = Menu.buildFromTemplate([{
			label: 'Item1',
			type: 'radio'
		},
		{
			label: 'Item2',
			type: 'radio'
		},
		{
			label: 'Item3',
			type: 'radio',
			checked: true
		},
		{
			label: 'Item4',
			type: 'radio'
		}
	])
	tray.setToolTip('This is my application.')
	tray.setContextMenu(contextMenu)

	// 监听单击事件
	tray.on('click', () => {
		console.log('Tray clicked');
	});

	// 监听右键事件
	tray.on('right-click', () => {
		console.log('Tray right-clicked');
	});

	// 监听双击事件
	tray.on('double-click', () => {
		console.log('Tray double-clicked');
	});
}

module.exports = {
	handleTray
}